<html>
<head><meta charset="utf-8"><title>Adding new builtin derive macro · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20new.20builtin.20derive.20macro.html">Adding new builtin derive macro</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="208754216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20new%20builtin%20derive%20macro/near/208754216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Wagner-Hall <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20new.20builtin.20derive.20macro.html#208754216">(Sep 01 2020 at 21:58)</a>:</h4>
<p>Hi! I'm trying to experiment with adding a new builtin derive macro in rustc, and I think I'm running into some bootstrap issues... I think I've made all of the code changes needed (it mirrors all of the ones <code>Clone</code> and <code>Hash</code> have), but when I <code>./x.py build</code> the stage0 compiler complains that <code>error: cannot find a built-in macro with name DwhMacro</code> - could anyone give me any hints for how to sidestep the fact that the bootstrap compiler doesn't have a definition for my macro?</p>
<p>Code changes I've made:</p>
<ul>
<li>Added to the list of symbols in src/librustc_span/symbol.rs</li>
<li>Added a <code>pub macro DwhMacro($item:item) { /* compiler built-in */}</code> block, and added it to the preludes in library/core/src/prelude/v1.rs and library/std/src/prelude/v1.rs</li>
<li>Added an impl, and added it to the map of macros in src/librustc_builtin_macros/lib.rs</li>
</ul>



<a name="208754311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20new%20builtin%20derive%20macro/near/208754311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20new.20builtin.20derive.20macro.html#208754311">(Sep 01 2020 at 21:59)</a>:</h4>
<p>The macro and all uses need to be behind <code>#[cfg(bootstrap)]</code></p>



<a name="208755413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20new%20builtin%20derive%20macro/near/208755413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Wagner-Hall <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20new.20builtin.20derive.20macro.html#208755413">(Sep 01 2020 at 22:11)</a>:</h4>
<p>Edit: Oh, it needs to be behind <code>#[cfg(not(bootstrap))]</code> - that makes sense, thanks!</p>



<a name="208756003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20new%20builtin%20derive%20macro/near/208756003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20new.20builtin.20derive.20macro.html#208756003">(Sep 01 2020 at 22:16)</a>:</h4>
<p>Err, yeah, sorry</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>